#ifndef E_PLUGIN_LOADER_H
#define E_PLUGIN_LOADER_H

#include <DefineCommon.h>
#include <DefineLibCommon.h>
#include <EPlugin.h>

struct EPluginLoaderData;
/**This class can be used to load *.dll file or *.so file, which will be used for plugin frmaework
 * Codes are based on DynamicLibrary in osgDB 
 * */
class COMMON_DLL EPluginLoader
{
public:

    static EPluginLoader* instance();

    /**call loadLibrary, new EpluginPtr, call exportFun, push_back to plugin list.*/
    void loadPlugin(const char* pluginName);
    /**Will load dll library simply*/
    bool loadLibrary(const char* libFileName, EPlugin::HandleDll& outHandle, EPlugin::Fun_Address& outFun);

    /*TODO: If it is necessary to code unloadPlugin function?*/

    size_t getPluginSize();
    EPluginPtr getPlugin(size_t index);
protected:
    EPluginLoader();
    virtual ~EPluginLoader();

    static EPluginLoader* m_instance;
    EPluginLoaderData* m_data;
};

#endif // E_PLUGIN_LOADER_H
